#ifndef __SOCKET_H__
#define __SOCKET_H__

#include <string>

enum class SOCK_TYPE
{
    RAW,
    TCP,
    UDP,
};

struct addrinfo;

class socket_t
{
    public:
        ~socket_t();

        void shutdown(bool read, bool write);
        int send(const std::string &buf);
        std::string recv();
    protected:
        void find_available_socket(const char *host, int port, addrinfo &hints);

        int sock = -1;
};

struct client_t : public socket_t
{
    void connect(const char *host, int port, SOCK_TYPE type);
};

struct server_t : public socket_t
{
    void bind(const char *host, int port, SOCK_TYPE type);
    void listen();
    void listen(int backlog);
    void accept();
};

#endif // !__SOCKET_H__
